<!DOCTYPE html>
<html lang="zh-CN">
<html lang="en">
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" href="./index.css">
</head>

<body>
    <title>Vue选项卡</title>
    <style>
        .header{
            position: absolute;
            top: 0;
            left: 10px;
            width: 300px;
            height: 50px;
        }
        ul {
            width: 100%;
            display: flex;
            list-style: none;
            padding: 0;
            margin: 0;
            background-color: #717181;
            font-size: 16px;
            line-height: 60px;
        }
        ul li {
            flex: 1;
            text-align: center;
            cursor: pointer;
            color: white;
        }
        .active {
            color: #fff;
            background: #e74c3c;
        }
        .box{
            position: absolute;
            top: 50px;
            left: 10px;
            width: 300px;
            height: 300px;
            background-color: skyblue;
            font-size: 30px;
            text-align: center;
        }
        .boxActive{
            margin-top: 100px;
        }
    </style>
</head>
<body>
    <!-- 将下面的数据，实现选项卡，并且要有样式的切换，样式不限 -->
    <div id="app">
        <div class="header">
            <ul>
                <li v-for="(item,index) in title" :class="{active:index == num}" v-on:click="getNum(index)">
                    {{item.item}}
                </li>
            </ul>
        </div>
        <div class="box">
            <div v-for='(item,index) in contents' :class="{boxActive:index == num}" v-show="index == num">
                {{item.item}}
            </div>
        </div>
    </div>
    <!-- 开发环境版本，包含了有帮助的命令行警告 -->
    <script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
    <script>
        let vm = new Vue({
            el:'#app',
            data:{
                num: 0,
                title:[
                    {item:'html'},
                    {item:'css'},
                    {item:'js'},
                    {item:'vuejs'}
                ],
                num: 0,
                contents:[
                    {item:'html-contents'},
                    {item:'css-contents'},
                    {item:'js-contents'},
                    {item:'vuejs-contents'}
                ]
            },
            methods:{
                getNum(index){
                    this.num = index;
                }
            }
        })
    </script>
</body>
</html>